package com.github.linkoog.model_designer.ide.editer.dbmodel.gutter.action;

import com.github.linkoog.model_designer.ide.editer.DDLSqlDialog;
import com.github.linkoog.model_designer.ide.editer.common.TableVo;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.yaml.psi.*;

import javax.swing.*;

public class ShowDDLAction extends AbstractTableAction {


    public ShowDDLAction(@NotNull YAMLFile yamlFile,@NotNull String tableName,@NotNull String text, String description, Icon icon) {
        super(yamlFile, tableName, text, description, icon);
    }

    @Override
    public void actionPerformed(@NotNull AnActionEvent e) {
        Project project = e.getData(CommonDataKeys.PROJECT);
        if (project == null) return;

        TableVo tableVo = getTableInfo(project);
        if (tableVo == null) return;

        DDLSqlDialog ddlSqlDialog = new DDLSqlDialog(project, tableVo);
        ddlSqlDialog.showAndGet();
    }



}
